package com.indigon.parkStory.data
{
	import com.indigon.parkStory.data.levels.ClusterData;
	import com.indigon.parkStory.data.levels.LevelData;
	import com.indigon.utils.XMLUtil;
	
	import flash.utils.Dictionary;

	public class GameData
	{
		private var _clusters : Vector.<ClusterData>;
		
		private static var _instance : GameData;
		
		public function GameData()
		{
		}
		
		public function init(levelsClass:Class):void
		{
			var i : uint = 1;
			
			var levelsXML : XML = XMLUtil.fileToXML(levelsClass);
			_clusters = new Vector.<ClusterData>();
			for each (var clusterXML : XML in levelsXML.cluster)
			{
				_clusters.push(new ClusterData(clusterXML, i));
				i++;
			}
		}
		
		public function getLevel(cluster:uint, level:uint):LevelData
		{
			return _clusters[cluster].levels[level];
		}
		
		public static function get instance():GameData
		{
			if (_instance == null) 
			{
				_instance = new GameData();
			}
			return _instance;
		}
	}
}